/**
 * Project Name:umale-maintenance
 * File Name:LoginController
 * Package Name:com.xuhaowei.mvc.jpa.controller
 * Date: 2020/3/14 下午1:29
 * Copyright (c) 2018, Neoglory-umale All Rights Reserved.
 */
package com.xuhaowei.mvc.jpa.controller;

import com.xuhaowei.mvc.jpa.common.ReturnData;
import com.xuhaowei.mvc.jpa.common.ReturnDataUtil;
import com.xuhaowei.mvc.jpa.common.User;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
 * @ClassName LoginController
 * @Description TODO
 * @Author xuhaowei
 * @Date 2020/3/14 下午1:29
 * @Version 1.0.0
 * @since JDK 1.8
 */

@RestController
@RequestMapping("/login")
public class LoginController {


    @PostMapping("/login")
    public ReturnData Login(String userName, String password,HttpSession session){
        if(null != userName && userName.equals("admin")){
            if(null != password && password.equals("admin")){
                User user = new User();
                user.setUserName(userName);
                user.setUserName(password);
                session.setAttribute("USER_SESSION",user);
                return ReturnDataUtil.success("success");
            }
        }
        return ReturnDataUtil.fail("fail");
    }
}